package com.www.applyword.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.www.applyword.R;
import com.www.applyword.bean.OrderBean;

/**
 * author : huang
 * date   : 2019/10/21 0021 15:06
 * version: 1.0
 *
 * @author Administrator
 */
public class MyJobAdapter extends CommonRecyclerAdapter<OrderBean> {

    public MyJobAdapter(Context context) {
        super(context, R.layout.item_list_job);
    }


    @Override
    public void onUpdate(BaseAdapterHelper helper, OrderBean item, int position) {
        helper.setText(R.id.tv_Order_PositionName, item.getOrder_PositionName());
       // helper.setText(R.id.tv_Order_EnterpriseName, (String) item.getOrder_EnterpriseName());

        if (TextUtils.isEmpty((String) item.getOrder_EnterpriseName())){
            helper.setText(R.id.tv_Order_EnterpriseName, item.getOrder_BusinessName());
        }else {
            helper.setText(R.id.tv_Order_EnterpriseName, (String)item.getOrder_EnterpriseName());
        }
        helper.setText(R.id.tv_Order_CreateTime, item.getOrder_CreateTime() + "  " + item.getOrder_Number() + "人");
        if (item.getOrder_SalaryType() == 0) {
            helper.setText(R.id.tv_Order_Salary, item.getOrder_Salary() + "/时");
          //  helper.setText(R.id.tv_Order_SalaryType, "时结");
        } else if (item.getOrder_SalaryType() == 1) {
            helper.setText(R.id.tv_Order_Salary, item.getOrder_Salary() + "/日");
         //   helper.setText(R.id.tv_Order_SalaryType, "日结");
        } else {
            helper.setText(R.id.tv_Order_Salary, item.getOrder_Salary() + "/月");
          //  helper.setText(R.id.tv_Order_SalaryType, "月结");
        }

        //Order_State 状态：0报名（录用和撤回）；1确认人员；2签到；3结算；4评价；10撤回；11待支付
        if (item.getOrder_State() == 0) {
            helper.setText(R.id.tv_Order_State, "报名中");
        } else if (item.getOrder_State() == 1) {
            helper.setText(R.id.tv_Order_State, "待确认");
        } else  if (item.getOrder_State() == 11 ) {
            helper.setText(R.id.tv_Order_State, "待支付");
        } else if (item.getOrder_State() == 2){
            helper.setText(R.id.tv_Order_State, "待签到");
        } else if (item.getOrder_State() == 3){
            helper.setText(R.id.tv_Order_State, "待结算");
        }else if (item.getOrder_State() == 4){
            helper.setText(R.id.tv_Order_State, "待评价");
        }else if (item.getOrder_State() == 10){
            helper.setText(R.id.tv_Order_State, "已撤回");
        }

        if (!TextUtils.isEmpty(item.getOrder_WorkAddress())) {
            if (item.getOrder_WorkAddress().contains(",")) {
                helper.setText(R.id.tv_Order_WorkAddress, item.getOrder_WorkAddress().split(",")[2]);
            } else {
                helper.setText(R.id.tv_Order_WorkAddress, item.getOrder_WorkAddress().split("-")[2]);
            }
        }
       /* helper.setText(R.id.tv_Order_BusinessName, item.getOrder_BusinessName());
        if (item.getOrder_PositionType() == 0) {
            helper.setText(R.id.tv_Order_PositionType, "兼职");
        } else {
            helper.setText(R.id.tv_Order_PositionType, "全职");
        }*/
      /*  if (item.getOrder_Type() == 0) {
            helper.setText(R.id.tv_Order_Type, "只可承包");
        } else if (item.getOrder_SalaryType() == 1) {
            helper.setText(R.id.tv_Order_Type, "承包和个人");
        } else {
            helper.setText(R.id.tv_Order_Type, "只可个人");
        }*/
     /*  if (!TextUtils.isEmpty(item.getOrder_Welfare())) {
            if (!item.getOrder_Welfare().contains(",")) {
                helper.setText(R.id.tv_Order_Welfare, item.getOrder_Welfare());
            } else {
                String mNames[] = item.getOrder_Welfare().split(",");
                for (int i = 0; i < mNames.length; i++) {
                    if (mNames.length < 3) {
                        helper.setText(R.id.tv_Order_Welfare, mNames[0]);
                        helper.getView(R.id.tv_Order_Welfare2).setVisibility(View.VISIBLE);
                        helper.getView(R.id.tv_Order_Welfare3).setVisibility(View.INVISIBLE);
                        // helper.getView(R.id.tv_Order_Welfare3).setVisibility(View.VISIBLE);
                        helper.setText(R.id.tv_Order_Welfare2, mNames[1]);
                        //  helper.setText(R.id.tv_Order_Welfare3, mNames[2]);
                    } else {
                        helper.setText(R.id.tv_Order_Welfare, mNames[0]);
                        helper.getView(R.id.tv_Order_Welfare2).setVisibility(View.VISIBLE);
                        helper.getView(R.id.tv_Order_Welfare3).setVisibility(View.VISIBLE);
                        helper.setText(R.id.tv_Order_Welfare2, mNames[1]);
                        helper.setText(R.id.tv_Order_Welfare3, mNames[2]);
                    }
                }
            }
        }*/
    }
}

